<template>
  <div class="login-pane">
    <h2 class="title">后台管理系统</h2>
    <el-tabs type="border-card" v-model="currentTab">
      <el-tab-pane label="User" name="account">
        <template #label>
          <span>
            <i class="el-icon-user-solid"></i>
            账号登录
          </span>
        </template>
        <LoginAccount ref="accountRef"></LoginAccount>
      </el-tab-pane>
      <el-tab-pane label="Config" name="phone">
        <template #label>
          <span>
            <i class="el-icon-mobile-phone"></i>
            手机登录
          </span>
        </template>
        <LoginPhone></LoginPhone>
      </el-tab-pane>
    </el-tabs>
    <div class="account-control">
      <el-checkbox v-model="isKeepPassword">记住密码</el-checkbox>
      <el-link type="primary">忘记密码</el-link>
    </div>
    <el-button type="primary" class="login-btn" @click="handleLoginClick">立即登录</el-button>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import LoginAccount from './LoginAccount.vue'
import LoginPhone from './LoginPhone.vue'

const isKeepPassword = ref<boolean>(true)
// const accountRef = ref<InstanceType<typeof LoginAccount>>()
const accountRef = ref()
const currentTab = ref('account')

const handleLoginClick = () => {
  if (currentTab.value === 'account') {
    accountRef.value?.loginAction(isKeepPassword.value)
  } else {
    console.log('手机号码登录')
  }
}
</script>

<style scoped lang="less">
.login-pane {
  width: 20rem;
  height: 100;
}
.title {
  text-align: center;
}

.account-control {
  margin-top: 10px;
  display: flex;
  justify-content: space-between;
}
.login-btn {
  width: 100%;
  margin-top: 10px;
}
</style>
